home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / winsock / twnsck12.zip / SRC\TERM.C < prev    next >
C/C++ Source or Header  |  1994-11-20  |  2KB  |  86 lines

  1. /*
  2.  *  TwinSock - "Troy's Windows Sockets"
  3.  *
  4.  *  Copyright (C) 1994  Troy Rollo <troy@cbme.unsw.EDU.AU>
  5.  *
  6.  *  This program is free software; you can redistribute it and/or modify
  7.  *  it under the terms of the GNU General Public License as published by
  8.  *  the Free Software Foundation; either version 2 of the License, or
  9.  *  (at your option) any later version.
  10.  *
  11.  *  This program is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *  GNU General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU General Public License
  17.  *  along with this program; if not, write to the Free Software
  18.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #ifndef NO_SGTTY_H
  22. #include <sgtty.h>
  23. #else
  24. #include <sys/ioctl.h>
  25. #endif
  26. #ifdef NEED_TTOLD_H
  27. #include <sys/ttold.h>
  28. #endif
  29.  
  30. #if !defined(CBREAK) && defined(O_CBREAK)
  31. #define CBREAK O_CBREAK
  32. #endif
  33. #if !defined(LITOUT) && defined(O_LITOUT)
  34. #define LITOUT O_LITOUT
  35. #endif
  36. #if !defined(PASS8) && defined(O_PASS8)
  37. #define PASS8 O_PASS8
  38. #endif
  39. #if !defined(DECCTQ) && defined(O_DECCTQ)
  40. #define DECCTQ O_DECCTQ
  41. #endif
  42. #if !defined(RAW) && defined(O_RAW)
  43. #define RAW O_RAW
  44. #endif
  45. #if !defined(ECHO) && defined(O_ECHO)
  46. #define ECHO O_ECHO
  47. #endif
  48. #if !defined(CRMOD) && defined(O_CRMOD)
  49. #define CRMOD O_CRMOD
  50. #endif
  51. #if !defined(TILDE) && defined(O_TILDE)
  52. #define TILDE O_TILDE
  53. #endif
  54. #if !defined(NOHANG) && defined(O_NOHANG)
  55. #define NOHANG O_NOHANG
  56. #endif
  57. #if !defined(CTLECH) && defined(O_CTLECH)
  58. #define CTLECH O_CTLECH
  59. #endif
  60.  
  61. struct    sgttyb Old;
  62. struct    sgttyb New;
  63.  
  64. void    InitTerm(void)
  65. {
  66.     ioctl(0, TIOCGETP, &Old);
  67.     New = Old;
  68.     New.sg_flags |= CBREAK | RAW;
  69. #ifdef PASS8
  70.     New.sg_flags |= PASS8;
  71. #endif
  72. #ifdef DECCTQ
  73.     New.sg_flags |= DECCTQ;
  74. #endif
  75. #ifdef LITOUT
  76.     New.sg_flags |= LITOUT;
  77. #endif
  78.     New.sg_flags &= ~(ECHO | CRMOD | TILDE | NOHANG | CTLECH);
  79.     ioctl(0, TIOCSETP, &New);
  80. }
  81.  
  82. void    UnInitTerm(void)
  83. {
  84.     ioctl(0, TIOCSETP, &Old);
  85. }
  86.